package com.bjsxt.chapter2_factory.simpleFactory;

/**
 * @ClassName Client
 * @Description
 * @Author 黑马程序员
 * @Date 16:28 2024/6/20
 * @Version 1.0
 **/
public class Client {
    public static void main(String[] args) {
        noFactory();

        factory();

        factory2();
    }

    // 未使用工厂模式，直接new的方式创建对象
    public static void noFactory() {
        Car c1 = new Audi();
        Car c2 = new Byd();

        c1.run();
        c2.run();
    }

    // 使用简单工厂模式创建对象
    public static void factory() {
       Car c1 = CarFactory.createCar("奥迪");
       Car c2 = CarFactory.createCar("比亚迪");

       c1.run();
       c2.run();
    }

    public static void factory2() {
        Car c1 = CarFactory2.createAudi();
        Car c2 = CarFactory2.createByd();

        c1.run();
        c2.run();
    }
}
